package com.showgood.view.component {
	import com.showgood.util.Path2I;
	import com.showgood.util.Point2I;
	import flash.display.Graphics;
	import flash.display.Sprite;
	
	/**
	 * 行军路线
	 * @author bianpeng
	 */
	public class MarchPath extends Sprite {
		private var _path:Path2I;
		public function MarchPath(path:Path2I=null) {
			super();
			this.path = path;
		}
		public function set path(path:Path2I):void {
			this._path = path;
			update_path();
		}
		public function get path():Path2I { return _path; }
		private function update_path():void {
			var g:Graphics = this.graphics;
			g.clear();
			if (_path == null ) return ;
			
			g.lineStyle(5, 0x7766ff, 0.3);
			g.moveTo(_path.nodeAt(0)._x, _path.nodeAt(0)._y);
			for (var i:int = 0, j:int = 1; j < _path.length; ++i, ++j) {
				var pi:Point2I = _path.nodeAt(i);
				var pj:Point2I = _path.nodeAt(j);
				g.lineTo(pj._x, pj._y);
			}
		}
	}
}
